<?php

/**
 *      [品牌空间] (C)2001-2010 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
 *
 *      $Id: index.php 5773 2011-11-07 06:14:07Z menglingmin $
 */

define('CURSCRIPT', 'index');
require_once('./common.php');
$bannerhtml = htmlspecialchars_decode($_G['brandads']['banner']);

$active['index'] = " class=\"active\"";
$location['title'] = $_G['setting']['site_nav']['index']['name'];

//首页最新入住商家
$_BCACHE->cachesql('new_shop', "SELECT itemid FROM ".DB::table("shopitems")." WHERE grade > 2 ORDER BY itemid DESC;", 0, 0, 4, 0, 'index', 'shop');
//店铺二级域名
$url = '';
$hostarr = explode('.', $_SERVER['HTTP_HOST']);
$domainroot = substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.') + 1);
if($_G['setting']['allowdomain'] && !empty($_G['setting']['domainroot']) && $domainroot == $_G['setting']['domainroot']) {
	if(count($hostarr) > 2 && $hostarr[0] != 'www' && !checkholddomain($hostarr[0])) {
		$prefixdomain = addslashes($hostarr[0]);
		$itemid = DB::result_first("SELECT itemid FROM ".DB::table('shopitems')." WHERE domain='$prefixdomain' LIMIT 1");
		if(!empty($itemid)) $url = 'store.php?id='.$itemid;
	}
}
//首页边栏商情
$shopnotice = array();
$query = DB::query("SELECT itemid,shopid,subject FROM ".DB::table('noticeitems')." WHERE shopid != '0' AND grade>2 ORDER BY itemid DESC LIMIT 8");
while($row = DB::fetch($query)) {
	$shopnotice[$row['itemid']]['shopid'] = $row['shopid'];
	$shopnotice[$row['itemid']]['subject'] = cutstr($row['subject'],20,true);

}
if(!empty($url)) {
	header("HTTP/1.1 301 Moved Permanently");
	header("location: $url");
}

include template('templates/site/default/index.html.php', 1);

ob_out();

?>
